package com.wxapp.admin.service.controller;

import com.wxapp.admin.api.pojo.vm.userCDJ.PCompanySelectVm;
import com.wxapp.admin.api.pojo.vm.userCDJ.PJobSelectVm;
import com.wxapp.admin.api.pojo.vm.userCDJ.PUserSelectVm;
import com.wxapp.admin.api.pojo.vo.userDeptJob.PAddUserDeptJobVo;
import com.wxapp.admin.service.service.UserCDJService;
import com.wxapp.common.constant.base.IBaseController;
import com.wxapp.common.constant.pojo.vm.ResultVm;
import com.wxapp.common.constant.pojo.vo.UserVo;
import com.wxapp.common.core.annotation.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lgl
 * @Description 用户部门岗位关联表
 * @Datetime 2022/8/13 18:52
 * @Modified By
 */
@RequestMapping("/ucdj")
@Tag(name = "用户部门岗位关联管理")
@RestController
@RequiredArgsConstructor
public class UserCDJController extends IBaseController {
    private final UserCDJService userCDJService;

    @GetMapping("/select/job")
    @Operation(summary ="得到所有岗位的下拉列表")
    public ResultVm<List<PJobSelectVm>> selectJob(@RequestParam(value = "name", required = false) String name, @RequestParam(value = "deptId", required = false) String deptId) {
        return userCDJService.selectJob(name, deptId);
    }

    @GetMapping("/getCompanyList")
    @Operation(summary ="公司下拉框")
    public ResultVm<List<PCompanySelectVm>> getCompanyList(@RequestParam(value = "name", required = false) String name) {
        return userCDJService.getCompanyList(name);
    }

    @PostMapping("add")
    @Operation(summary ="用户设置部门和岗位信息")
    public ResultVm<String> addUserDeptJob(@Schema(hidden = true) @User UserVo userVo, @RequestBody PAddUserDeptJobVo pAddUserDeptJobVo) {
        return userCDJService.addUserDeptJob(userVo, pAddUserDeptJobVo);
    }

    @GetMapping("userSelect")
    @Operation(summary ="获取用户下拉框")
    public ResultVm<List<PUserSelectVm>> userSelect(@RequestParam(value = "companyId", required = false) String companyId) {
        return userCDJService.userSelect(companyId);
    }
}
